package com.ctg.itrdc.sysmgr.portal.utils;

import java.net.URLEncoder;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSON;

public class CookieUtils {

	public static void setCookie(HttpServletResponse response, String key,
			Object value) {
		if(StringUtils.isNotBlank(key) && value!=null){
			Cookie cookie = new Cookie(key,
					URLEncoder.encode(JSON.toJSONString(value)));
			response.addCookie(cookie);
		}
	}
}
